/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controlador;

import comu.Configuracio;
import controlador.autogenerats.AbonoJpaController;
import entity.Abono;
import entity.Producte;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.Query;

/**
 *
 * @author David
 */
public class AbonoControlador extends AbonoJpaController{

    public AbonoControlador() {
        super(Persistence.createEntityManagerFactory(Configuracio.PERSISTANCE_UNIT));
    }

    public List findAbonoEntitiesAZ() {
        EntityManager em = getEntityManager();
        try{
        Query q = em.createNativeQuery("select * from abono order by nom", Abono.class);
        Iterator it = q.getResultList().iterator();
        ArrayList<Abono> llista = new ArrayList<Abono>();
        while(it.hasNext()){
            llista.add((Abono) it.next());
        }
        return llista;
        } finally {
            em.close();
        }
    }
    
    
}
